from flask import Flask

from utils.utils import get_xml_value

from res.user import user

from models import db

from res.book import book

app = Flask(__name__)

app.config['SQLALCHEMY_DATABASE_URI'] = get_xml_value('CONN')[1]

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True

with app.app_context():
    db.init_app(app)
    db.create_all()


@app.route('/')
def hello_world():
    return 'Hello World!'


app.register_blueprint(user, url_prefix='/api')

app.register_blueprint(book, url_prefix='/api')

if __name__ == '__main__':
    app.debug = True
    app.run()
